#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iostream>
 
using namespace std;


  struct ListNode {
      int val;
      ListNode *next;
      ListNode(int x) : val(x), next(nullptr) {}
  };
 
class Solution {
public:
    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
        int carry = 0,
           sum  = 0;
        ListNode *p1 = l1, *p2 = l2;
        ListNode *result = nullptr, *tail = nullptr ;
         
        while (p1 != nullptr || p2 != nullptr){
            if( p1 != nullptr  && p2 != nullptr) {
                sum = p1->val + p2->val + carry;
                carry  = sum / 10;
                sum   = sum % 10;
                p1 = p1->next;
                p2 = p2->next;
            }
            else if ( p1 == nullptr && p2 != nullptr )
            {
                sum =   p2->val  + carry; 
                carry  = sum / 10;
                sum   = sum % 10;
                                
                p2 = p2->next;
            }else if( p1 != nullptr && p2  == nullptr){
                sum =   p1->val  + carry;
                carry  = sum / 10;
                sum   = sum % 10;
                p1 = p1->next;
            }
            //cout<<"sum" <<sum<<endl;
            ListNode *tmp = new ListNode(sum);
            

            if( tail != nullptr){
               tail->next = tmp;
               tail = tmp; 
            }
            else{
             tail = result = tmp;
            }          

        }
  
        if(carry != 0){
           ListNode *tmp = new ListNode(carry);
           tmp->val    = carry;

           if( tail != nullptr){
               tail->next = tmp;
               tail = tmp; 
           }
           else{
              tail = tmp;
           }
        }
                
           
        return result;
    }
};


void trimLeftTrailingSpaces(string &input) {
    input.erase(input.begin(), find_if(input.begin(), input.end(), [](int ch) {
        return !isspace(ch);
    }));
}

void trimRightTrailingSpaces(string &input) {
    input.erase(find_if(input.rbegin(), input.rend(), [](int ch) {
        return !isspace(ch);
    }).base(), input.end());
}

vector<int> stringToIntegerVector(string input) {
    vector<int> output;
    trimLeftTrailingSpaces(input);
    trimRightTrailingSpaces(input);
    input = input.substr(1, input.length() - 2);
    stringstream ss;
    ss.str(input);
    string item;
    char delim = ',';
    while (getline(ss, item, delim)) {
        output.push_back(stoi(item));
    }
    return output;
}

ListNode* stringToListNode(string input) {
    // Generate list from the input
    vector<int> list = stringToIntegerVector(input);

    // Now convert that list into linked list
    ListNode* dummyRoot = new ListNode(0);
    ListNode* ptr = dummyRoot;
    for(int item : list) {
        ptr->next = new ListNode(item);
        ptr = ptr->next;
    }
    ptr = dummyRoot->next;
    delete dummyRoot;
    return ptr;
}

string listNodeToString(ListNode* node) {
    if (node == nullptr) {
        return "[]";
    }

    string result;
    while (node) {
        result += to_string(node->val) + ", ";
        node = node->next;
    }
    return "[" + result.substr(0, result.length() - 2) + "]";
}

int main2(int i, char *argv[]) {
    string line;
    while (getline(cin, line)) {
        ListNode* l1 = stringToListNode(line);
        getline(cin, line);
        ListNode* l2 = stringToListNode(line);
        
        ListNode* ret = Solution().addTwoNumbers(l1, l2);

        string out = listNodeToString(ret);
        cout << out << endl;
    }
    return 0;
}